package org.ttjhome.server;

import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.hibernate.cfg.Environment;





public class HunterServiceFactory {
	private static HunterService service;
	
	
	
	public static HunterService createHunterService() {
		
		
		if(service==null){
		
			Map<String, String> props = new HashMap<String, String>();
			props.put(Environment.HBM2DDL_AUTO, "update");
			EntityManagerFactory entityManagerFactory = Persistence
					.createEntityManagerFactory("simpleHunter", props);
			
			service = (HunterService) (Proxy.newProxyInstance(
					HunterService.class.getClassLoader(),
					new Class[] { HunterService.class },
					new ServiceProxy(entityManagerFactory, new HunterServiceImpl())));
			
			
		}
		return service;
	}
}
